package com.xmg.nacos;



import javax.naming.event.NamingEvent;
import java.io.IOException;
import java.time.LocalTime;
import java.util.List;
import java.util.Properties;
import java.util.concurrent.TimeUnit;

/**
 * @Author: mazhongqing
 * @Date: 2021/3/10 12:22
 */
public class NacosTest {
    public static void main(String[] args) throws IOException, InterruptedException {
//        Properties properties = new Properties();
//        properties.setProperty("serverAddr","81.70.179.30:8848");
////        properties.setProperty("namespace","default");
//
//        NamingService naming = NamingFactory.createNamingService(properties);
//        naming.registerInstance("test","192.168.3.34",9099,"123");
//        naming.registerInstance("test","192.168.3.35",9088,"125");
//        List<Instance> list = naming.getAllInstances("test");
////        System.out.println(list);
////        while (true){
////            System.out.println(LocalTime.now()+" "+list.size());
////            TimeUnit.SECONDS.sleep(1);
////        }
//
//        naming.subscribe("test", new EventListener() {
//            @Override
//            public void onEvent(Event event) {
//                System.out.println(((NamingEvent)event).getServiceName());
//                System.out.println(((NamingEvent)event).getInstances());
//            }
//        });
////        System.in.read();
//
////        System.out.println(TimeUnit.SECONDS.toMillis(5));
    }
}
